<?php

namespace App\Transformers;

use App\Models\Collect;
use League\Fractal\TransformerAbstract;
use App\Models\Comment;
class CommentTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['movie', 'author'];

    public function transform(Comment $comment)
    {
        return [
            'id' => $comment->id,
            'content' => $comment->content,
            'created_at' => (string) $comment->created_at,
            'updated_at' => (string) $comment->updated_at,
            'user_id' => $comment->user_id,
            'source' => $comment->source,
        ];
    }

    public function includeMovie(Comment $comment)
    {
        return $this->item($comment->movie, new MovieTransformer);
    }
    public function includeAuthor(Comment $comment)
    {
        return $this->item($comment->author, new UserTransformer);
    }
}
